package com.fh.controller;/**
 * 描述:
 * Author:袁亚强
 * Date:2021/11/2317:22
 */

import com.fh.common.yyqData;
import com.fh.entity.po.Value;
import com.fh.service.ValueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * created by macro on 2021/11/23,
 */
@RestController
@RequestMapping("value")
public class ValueController {

    @Autowired
    private ValueService valueService;

    @PostMapping("queryByIdData")
    public yyqData queryByIdData(Integer id){
        if (id==null){
            return yyqData.error(400,"缺少参数");
        }
        return yyqData.success(valueService.queryByIdData(id));
    }
    @PostMapping("updateValue")
    public yyqData updateValue(Value value){
        if (value.getId()==null){
            return yyqData.error(400,"缺少参数");
        }
        valueService.updateValue(value);
        return yyqData.success("");
    }

    @GetMapping("queryByIdValue")
    public yyqData queryByIdValue(Integer id){
        if (id==null){
            return yyqData.error(400,"缺少参数");
        }
        return yyqData.success(valueService.queryByIdValue(id));
    }


    @PostMapping("addValue")
    public yyqData addValue(Value value){
        if (value.getAid()==null){
            return yyqData.error(400,"缺少参数");
        }
        if (StringUtils.isEmpty(value.getValue())){
            return yyqData.error(400,"缺少参数");
        }
        if (StringUtils.isEmpty(value.getValueId())){
            return yyqData.error(400,"缺少参数");
        }
        valueService.addValue(value);
        return yyqData.success("");
    }
}
